<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>个人中心</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="http://at.alicdn.com/t/font_956742_if4u2ec187h.css">
    <style>
        body {
            background: #f6f6f6;
        }

        .header {
            width: 100%;
            height: 6.5rem;
            background-color: #FEE407;
        }

        .top-shadow {
            position: absolute;
            box-shadow: 0px 10px 15px 0px #888;
            height: 5px;
            width: 100%;
            top: -18px;
        }

        .header .img_box {
            width: 3rem;
            height: 3rem;
        }

        .header .img_box img {
            width: 100%;
            border-radius: 100%;
        }

        .header .nickname {
            font-size: 1rem;
            color: #333;
            font-weight: bold;
            margin-left: 0.75rem;
        }

        .main {
            background: #fff;
        }

        .hj_list {
            border-bottom: 1px solid #F6F6F6;
            padding-top: 0.5rem;
            padding-bottom: 0.5rem;
        }

        .hj_list .img_box {
            width: 1rem;
            height: 1rem;
            padding: 0.25rem 0.5rem;
        }

        .hj_list .img_box img {
            width: 100%;
        }

        .main_content {
            width: 0;
            overflow: hidden;
            padding-left: 0.5rem;
        }

        .main_content .title {
            font-size: 0.7rem;
            color: #333;
        }

        .hj_modal {
            display: none;
            height: 100%;
            width: 100%;
            position: fixed;
            overflow: hidden;
            z-index: 99;
            background-image: linear-gradient(-180deg, rgba(254, 228, 7, 0.59) 0%, #F7D21C 91%);
        }

        .hj_modal .bottom {
            padding: 2rem 2rem 0rem 2rem;
        }

        .hj_modal .logo_title {
            text-align: left;
            padding-bottom: 1.25rem;
        }

        .hj_modal .logo_title img {
            width: 50%;
        }

        .hj_modal .login_desc {
            font-size: 1rem;
            font-weight: 600;
        }

        .hj_modal .desc {
            font-size: 0.8rem;
            font-weight: 600;
        }

        .hj_modal .wechat {
            margin-top: 2rem;
            margin-bottom: 1rem;
            text-align: center;
        }

        .hj_modal .wechat img {
            width: 2.5rem;
        }

        .hj_modal .agreement {
            font-size: 0.7rem;
            color: #4a4a4a;
            text-align: center;
            margin-bottom: 2rem;
        }

        .hj_modal a {
            font-size: 0.7rem;
            color: #fabd86;
            text-decoration: underline;
        }

        .hj_modal .btn {
            text-align: right;
            padding: 0rem 1rem;
        }

        .hj_modal .btn img {
            width: 1rem;
        }

        .hj_modal_switch {
            display: none;
            height: 100%;
            width: 100%;
            position: fixed;
            overflow: hidden;
            z-index: 99;
            background: rgba(5, 5, 5, 0.5);
        }

        .hj_modal_switch .hj_list_header {
            border-bottom: 1px solid #F6F6F6
        }

        .hj_modal_switch .hj_list_header .title {
            font-size: 0.8rem;
            text-align: center;
            padding: 0.5rem;
        }

        .hj_modal_switch .hj_list_header .btn_right {
            position: absolute;
            right: 0.5rem;
            width: 0.8rem;
        }

        .hj_modal_switch .hj_list_header .btn_right img {
            width: 100%;
        }

        .hj_modal_switch .hj_list {
            padding: 0.75rem 0.75rem;
        }

        input[type="radio" i] {
            -webkit-appearance: none;
        }

        .hj_modal_switch .hj_list .switch_radio {
            width: 1rem;
            height: 1rem;
        }

        .hj_modal_switch .hj_list .switch_radio_active {
            background: url(../images/switch_active.png);
            background-size: 100%;
        }
    </style>
</head>

<body>
    <div id="app">
        <div id="login" class="hj_modal flex_column">
            <div class="btn btn_right">
                <img onclick="closeLogin()" src="../images/close.png" alt="">
            </div>
            <div class="flex_1">

            </div>
            <div class="bottom">
                <div class="logo_title">
                    <img src="../images/login_title.png" alt="">
                </div>
                <div class="login_desc">
                    登陆
                </div>
                <div class="desc">
                    开启老妖精学习之旅
                </div>

                <div class="wechat">
                    <img onclick="login(1)" src="../images/wechat.png" alt="">
                    <div style="font-size: 0.7rem;">微信</div>
                </div>
            </div>
            <div class="agreement">
                登录即表示您同意并愿意遵守老妖精<a href="">（用户协议）</a>
            </div>
        </div>

        <div id="switch" class="hj_modal_switch">
            <div onclick="closeSwitch()" style="height:100%" class="flex_column flex_end">

                <div onclick="_eventPrevent(event)" style="background:#fff" class="wrap hj_margin_t_5">
                    <div class="hj_list_header">
                        <div style="position: relative;" class="flex flex_column_center">
                            <div class="flex_1 flex_column flex_around">
                                <div class="title">切换科目</div>
                            </div>
                            <div onclick="closeSwitch()" class="btn btn_right">
                                <img src="../images/close.png" alt="">
                            </div>
                        </div>
                    </div>


                    <template v-for="(item,index) in data">
            <div onclick="chooseSubject(this)" class="hj_list">
              <div class="flex flex_column_center">
                <div class="input_box flex flex_center">
                  <label class="switch_radio" v-bind:class="isActive(index)"></label>
                  <input type="radio" name="subject" :value="index">
                </div>
                <div class="main_content flex_1 flex_column flex_around">
                  <div class="title">{{item.text}}</div>
                </div>
              </div>
            </div>
        </template>

                </div>

            </div>
        </div>

        <div class="header flex flex_column_center">
            <div class="top-shadow"></div>
            <div class="hj_margin_1">
                <div onclick="openLogin()" class="flex">
                    <div class="img_box">
                        <img id="logo" class="logo" src="../images/logo.png" alt="">
                    </div>
                    <div id="nickname" class="nickname">未登录</div>
                </div>
            </div>
        </div>

        <div class="main">
            <div class="wrap hj_margin_5">

                <div class="wrap hj_margin_t_5">
                    <div onclick="openDownload()" class="hj_list">
                        <div class="flex flex_column_center">
                            <div class="img_box flex flex_center">
                                <img class="logo" src="../images/mine-download.png" alt="">
                            </div>
                            <div class="main_content flex_1 flex_column flex_around">
                                <div class="title">离线缓存</div>
                            </div>
                            <div class="right">
                                <i class="iconfont icon-right"></i>
                            </div>
                        </div>
                    </div>

                    <div onclick="openHistory()" class="hj_list">
                        <div class="flex flex_center">
                            <div class="img_box flex flex_center">
                                <img class="logo" src="../images/mine-history.png" alt="">
                            </div>
                            <div class="main_content flex_1 flex_column flex_around">
                                <div class="title">观看历史</div>
                            </div>
                            <div class="right">
                                <i class="iconfont icon-right"></i>
                            </div>
                        </div>
                    </div>

                    <div onclick="openWin('mine-settings')" class="hj_list">
                        <div class="flex flex_center">
                            <div class="img_box flex flex_center">
                                <img class="logo" src="../images/mine-settings.png" alt="">
                            </div>
                            <div class="main_content flex_1 flex_column flex_around">
                                <div class="title">设置</div>
                            </div>
                            <div class="right">
                                <i class="iconfont icon-right"></i>
                            </div>
                        </div>
                    </div>

                    <div class="hj_list">
                        <div class="flex flex_center">
                            <div class="img_box flex flex_center">
                                <img class="logo" src="../images/mine-switch.png" alt="">
                            </div>
                            <div onclick="openSwitch()" class="main_content flex_1 flex_column flex_around">
                                <div class="title">切换科目</div>
                            </div>
                            <div class="right">
                                <i class="iconfont icon-right"></i>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/util.js"></script>
<script type="text/javascript" src="../script/vue.min.js"></script>
<script type="text/javascript">
    var app = '';
    var wx;
    var zhibo;

    var host = host;


    apiready = function() {
        zhibo = api.require("liveplayermodule");
        console.log(level_id);
        wx = api.require('wx');
        setInfo();

        app = new Vue({
            el: '#app',
            data: {
                data: []
            },
            methods: {
                isActive(value) {
                    if (value == level_id) {
                        console.log(value + "===" + level_id);
                        return 'switch_radio_active';
                    }
                }
            },
            updated: function() {
                console.log("更新了");
            }
        });

        getLevel();
    };

    function getLevel() {
        api.ajax({
            url: 'https://api.laoyaojing.net/Public/getMajorList',
            method: 'get',
        }, function(ret, err) {
            if (ret) {
                // console.log(JSON.stringify(ret));
                if (ret.code == 200) {
                    data = ret.result.apps;
                    app.data = ret.result.apps;
                    console.log(JSON.stringify(app.data));
                }
            } else {
                alert(JSON.stringify(err));
            }
        });

    }

    function setInfo() {

        if (typeof(userinfo) != "undefined" && userinfo != null && token != '-1') {
            console.log(headpic);
            var dom = $api.byId('logo');
            $api.text($api.byId('nickname'), userinfo.nickname);
            $api.attr(dom, 'src', headpic);
        } else {
            var dom = $api.byId('logo');
            $api.attr(dom, 'src', "../images/logo.png");
            $api.text($api.byId('nickname'), "未登录");
        }

    }

    //打开新页面
    function openWin(name) {
        api.openWin({
            name: name,
            url: name + '.html'
        });

    }

    //打开登陆遮罩层
    function openLogin() {
        console.log(token);
        if (token == '-1' || typeof(token) == "undefined" || token == null) {
            $api.attr($api.byId("login"), "style", "display:flex");
        }
    }

    //关闭登陆遮罩层
    function closeLogin() {
        $api.attr($api.byId("login"), "style", "display:none");
    }

    //打开科目选择
    function openSwitch() {
        $api.attr($api.byId("switch"), "style", "display:block");
    }

    //关闭科目选择
    function closeSwitch() {
        $api.attr($api.byId("switch"), "style", "display:none");
    }

    function _eventPrevent(event) {
        event.stopPropagation();
    }

    function openHistory() {
        if (token == '-1') {
            api.openWin({
                name: 'login',
                reload: true,
                url: './login.html',
            });
        } else {
        //alert(host);
            var param = {
                token: token,
                app: from,
                major_type: major_type,
                urlTitle: host,
                username:username
            }
            zhibo.openHistory(param);
        }
    }

    function openDownload() {
        if (token == '-1') {
            api.openWin({
                name: 'login',
                reload: true,
                url: './login.html',
            });
        } {
            zhibo.openDownload();
        }
    }

    //选择当前
    function chooseSubject(obj) {
        var dom = $api.dom(obj, 'input');

        console.log(dom.value);

        var from1 = data[dom.value]['app'];
        console.log(from1);
        var major_type1 = data[dom.value]['major_type'];
        console.log(major_type1);

        var host1 = data[dom.value]['host'];

        host = host1;

        var text = data[dom.value]['text'];

        $api.setStorage('level_id', dom.value);
        $api.setStorage('from', from1);
        $api.setStorage('major_type', major_type1);
        $api.setStorage('host', host1);
        $api.setStorage('text', text);

        getMiniId();

        dom.checked = true;
        //移除选中label
        var label_active = $api.dom('.switch_radio_active');
        $api.removeCls(label_active, 'switch_radio_active');

        //单选label
        var label = $api.dom(obj, 'label');
        $api.addCls(label, 'switch_radio_active');

        // api.execScript({
        //     name: 'root',
        //     frameName: 'lesson',
        //     script: 'window.location.reload()'
        // });
    }
</script>

</html>
